<template>
  <el-drawer
    v-if="visible"
    :visible.sync="visible"
    :with-header="false"
    :append-to-body="true"
    size="900px"
  >
    <div class="title">
      <div class="title-text">围栏单量详情</div>
    </div>
    <div class="center">
      <el-table
        :data="tableData.detailList"
        style="width: 100%;"
      >
        <el-table-column
          type="index"
          width="50"
          label="#"
        />
        <el-table-column
          prop="orgName"
          label="站点围栏"
          width="180"
        />
        <el-table-column
          prop="count"
          label="站点围栏单量"
          width="140"
        />
        <el-table-column
          prop="bottleCount"
          label="站点围栏订单瓶数"
          width="140"
        />
        <el-table-column
          prop=""
          label="统计日期"
        >
          <template>
            <span>{{ parseTime(tableData.statStartTime, '{y}-{m}-{d}') + ' ~ ' + parseTime(tableData.statEndTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
      </el-table>

    </div>

    <!-- 底部 -->
    <div class="demo-drawer__footer" style="padding: 0 10px 10px 0; text-align: right;">
      <div class="btn-group">
        <div class="btns">
          <el-button v-if="currentRow.fenceStatus === 1" v-permission="5" type="danger" @click="$emit('del', currentRow);visible=false;">作废</el-button>
        </div>
        <el-button @click="visible = false"> 关闭 </el-button>
      </div>
    </div>
  </el-drawer>
</template>

<script>
  import { fenceReserveApplyDetail } from '@/api'
  import { parseTime } from '@/utils'
  export default {
    name: 'fenceDetail',
    data() {
      return {
        visible: false,
        currentRow: {},
        tableData: []
      }
    },
    methods: {
      parseTime,
      open(row) {
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
          if (row) {
            this.currentRow = Object.assign(this.currentRow, row)
            this.getDetail()
          }
        })
      },
      async getDetail() {
        const params = {
          id: this.currentRow.id
        }
        const res = await fenceReserveApplyDetail(params)
        if (res && res.data) {
          this.tableData = res.data
        }
      },
      reset() {
        this.visible = false
      }

    }

  }
</script>

<style lang="scss" scoped>
/deep/.el-drawer__header {
  padding: 15px 20px;
  margin-bottom: 0;
}

.title {
  display: flex;
  padding: 20px 20px 0 20px;
  margin-bottom: 20px;
  .title-text {
    line-height: 25px;
  }
  .tag {
    margin: 0 10px;
  }
}
.center {
  padding: 0 10px;
}
.demo-drawer__footer {
  position: fixed;
  bottom: 0;
  width: 900px;
  height: 55px;
  background: white;
  border: 2px solid #DCDFE6;
  .btn-group {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    margin-right: 10px;
    .btns {
      margin-left: 15px;
    }
  }
}
</style>
